﻿/*
 * 绘制报告的基类
 * */
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WH.NurseSys.Model;

namespace WH.NurseSys.BLL.Report
{
    public class DrawReport
    {
        //绘制基本信息，hardMarginX,hardMarginY都是以mm为单位
        protected void drawInfo(Graphics dc, Patient patient, string reportTitle)
        {
            Font titleFont = new Font("宋体", 18, FontStyle.Bold, GraphicsUnit.Point);
            Font textFont = new Font("宋体", 14, FontStyle.Regular, GraphicsUnit.Point);
            float titleWidth = dc.MeasureString(reportTitle, titleFont).Width;
            dc.DrawString(reportTitle, titleFont, Brushes.Black, 15*dotPerMm+((210-15*2)*dotPerMm-titleWidth)/2, 15 * dotPerMm);
            Pen linePen=new Pen(Brushes.Black,4);
            float yLine = 15 * dotPerMm + titleFont.GetHeight(dc);
            float xLeft=15*dotPerMm;
            float xRight=(210-15)*dotPerMm;
            dc.DrawLine(linePen, 15 * dotPerMm, yLine, (210 - 15) * dotPerMm, yLine);
            //
            float x1=15*dotPerMm;
            float y1=15*dotPerMm+titleFont.GetHeight(dc)+6;
            float x2 = (15+60) * dotPerMm;
            float x3 = (15 + 60 + 60) * dotPerMm;         
            float y2=y1+textFont.GetHeight(dc);
            float y3 = y2 + textFont.GetHeight(dc);
            float yLine2=y3+textFont.GetHeight(dc);
            dc.DrawString("姓名:" + patient.Name, textFont, Brushes.Black, x1, y1);
            dc.DrawString("性别:" + (patient.Gender ? "男" : "女"), textFont, Brushes.Black, x2, y1);
            dc.DrawString("年龄:" + patient.Age + (patient.AgeUnit == "D" ? "天" : "岁"), textFont, Brushes.Black, x3, y1);
            dc.DrawString("住院号:" + patient.InpatientNo, textFont, Brushes.Black, x1, y2);
            dc.DrawString("床号:" + patient.BedNo, textFont, Brushes.Black, x2, y2);
            dc.DrawString("负责医生:" + patient.Doctor, textFont, Brushes.Black, x3, y2);
            dc.DrawString("科室:" + patient.DeptName, textFont, Brushes.Black, x1, y3);
            dc.DrawLine(linePen, xLeft, yLine2, xRight, yLine2);
            titleFont.Dispose();
            textFont.Dispose();
            linePen.Dispose();
        }

        protected float dotPerMm = 300/25.39999f;
    }
}
